package ai.leinao.alarm.domain;

import lombok.Data;

import java.util.Date;
import java.util.Map;

/**
 * 原始报警
 *
 * @author zhong.wang
 * @date 2025/9/3
 **/
@Data
public class RawAlarm {
    /**
     * 报警id
     */
    private Long id;

    /**
     * 报警类型
     */
    private String mainType;

    /**
     * 子类型
     */
    private String subType;

    /**
     * 报警内容
     */
    private String alarmContent;

    /**
     * 报警级别
     */
    private String alarmLevel;

    /**
     * 报警时间
     */
    private Date alarmTime;

    /**
     * 报警开始时间
     */
    private Date alarmStartTime;

    /**
     * 报警结束时间
     */
    private Date alarmEndTime;

    /**
     * 设备id
     */
    private Long deviceId;

    /**
     * 设备类型码
     */
    private String deviceTypeCode;

    /**
     * 站点id
     */
    private Long stationId;

    /**
     *  区域id
     */
    private Long stationAreaId;

    /**
     * 衍生属性
     */
    private Map<String, Object> derivedProperties;

    /**
     * 报警指纹
     */
    private String fingerprint;

    /**
     * 报警数量
     */
    private Integer alarmCount = 1;

    /**
     * 转换成Map
     *
     * @return
     */
    public Map<String, String> getContext() {
        Map<String, String> map = new java.util.HashMap<>();
        map.put("id", String.valueOf(this.id));
        map.put("mainType", this.mainType);
        map.put("subType", this.subType);
        map.put("alarmContent", this.alarmContent);
        map.put("alarmLevel", this.alarmLevel);
        map.put("deviceTypeCode", this.deviceTypeCode);
        map.put("deviceId", String.valueOf(this.deviceId));
        map.put("stationId", String.valueOf(this.stationId));
        map.put("stationAreaId", String.valueOf(this.stationAreaId));
        derivedProperties.forEach((k, v) -> map.put(k, String.valueOf(v)));
        return map;
    }
}
